package com.cloud.pole.shop.biz.goods;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear;
import com.cloud.pole.common.biz.BaseBiz;
import com.cloud.pole.mapper.goods.ShopGoodsGroupMapper;
import com.cloud.pole.mapper.goods.ShopGoodsGroupRecommMapper;
import com.cloud.pole.shop.model.entity.goods.ShopGoodsGroup;
import com.cloud.pole.shop.model.entity.goods.ShopGoodsGroupRecomm;

@Service
@Transactional(rollbackFor = Exception.class)
public class ShopGoodsGroupBiz extends BaseBiz<ShopGoodsGroupMapper, ShopGoodsGroup> {
	
	@Cache(key="shopGoodsGroupList{1}-shopId{2}-recommPosId")
    public List<ShopGoodsGroup> getListByShop(Integer shopId, Integer recommPosId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("shopId", shopId);
		map.put("recommPosId", recommPosId);
		return mapper.getListByShop(map);
    }
	
	public List<ShopGoodsGroup> selectByAll(){
		return mapper.selectByShopsGroup();
	}
	
	public List<ShopGoodsGroup> selectByShopGoodsGroup(){
		return mapper.selectByGoodsGroupList();
	}
	
	@CacheClear(pre="shopGoodsGroupList{1.shopId}")
	public void createShopGoods(ShopGoodsGroup shopGoodsGroup) {
		mapper.insertShopGoods(shopGoodsGroup);
	}
	
	public ShopGoodsGroup selectGroup(Integer groupId) {
		return mapper.selectByIdGroup(groupId);
	}
	
	@CacheClear(pre="shopGoodsGroupList{1.shopId}")
	public void updateShopGroup(ShopGoodsGroup shopGoodsGroup) {
		mapper.updateShopGroupes(shopGoodsGroup);
	}
	
	@CacheClear(pre="shopGoodsGroupList{1.shopId}")
	public void deleteGroups(ShopGoodsGroup shopGoodsGroup) {
		mapper.deleteShopGroups(shopGoodsGroup);
	}
	
	public List<ShopGoodsGroup> selectByShopsStatus(Integer shopId) {
		return mapper.selectByStatus(shopId);
	}
}
